package mongodb

import (
	"context"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
	"time"
)

var database = "mongocrud"
var table = "cruds"
var Client *mongo.Client
var UserCollection *mongo.Collection

func InitMongo() {
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()

	clientOptions := options.Client().ApplyURI("mongodb://localhost:27017")
	Client, _ = mongo.Connect(ctx, clientOptions)
	UserCollection = Client.Database("test").Collection("users")
}
